package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
    Page<DishVO> page(DishPageQueryDTO dto);

    DishVO getById(Long id);

    List<Dish> getByCategoryId(Long id);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    @AutoFill(OperationType.INSERT)
    long addDish(Dish dish);

    @Select("SELECT * FROM dish WHERE name=#{name}")
    Dish getByName(String name);

    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);

    List<Dish> getByCategoryIdAndName(DishDTO dto);


    List<Dish> list(Dish dish);

    Integer countByMap(Map map);
}
